package org.example;

import org.example.dao.BookDao;
import org.example.domain.Brand;
import org.example.service.BookService;
import org.example.service.BrandService;
import org.example.service.BrandServiceImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.sql.DataSource;
import java.util.List;

// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
// then press Enter. You can now see whitespace characters in your code.
public class Main {
    public static void main(String[] args) {
//        ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml.bak");
        ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
//        使用配置类完成配置
        BrandService brandService = context.getBean(BrandService.class);
        List<Brand> brands = brandService.lookUp();
        System.out.println(brands);

        BookDao bookDao = (BookDao)context.getBean("bookDao");
        DataSource dataSource=context.getBean(DataSource.class);
        BookService bookService=(BookService)context.getBean("bookService");
        System.out.println(dataSource);
        bookService.service();
//        bookDao.save();

    }
}